/**
 * Created by dev on 15-7-17.
 */
(function () {
  'use strict';

  angular
    .module('vboxApp')
    .factory('dashboardSummaryRepo', dashboardSummaryRepo);

  /** @ngInject */
  function dashboardSummaryRepo($http, CommonVar) {
    return {
      //获取所有文件
      getFiles: function (page, callback) {
        $http.get(CommonVar.url + 'file/list?size=20&page=' + (page - 1)).success(function (data) {
          callback(data);
        });
      },
      //获取所有文件
      getSummaryFiles: function (callback) {
        $http.get(CommonVar.url + 'file/share').success(function (data) {
          callback(data);
        });
      },
      //文件申诉
      appealFile: function (id, context, callback) {
        $http.post(CommonVar.url + 'file/appeal?id=' + id, context).success(function (data) {
          callback(data);
        });
      },
      //处理申诉
      dealFile: function (id, context, callback) {
        $http.post(CommonVar.url + 'file/answer?id=' + id, context).success(function (data) {
          callback(data);
        });
      },
      //下载
      downloadFile: function (callback) {
        $http.get(CommonVar.url + 'oss/url').success(function (data) {
          callback(data);
        });
      },
      //文件删除
      deleteFile: function (id, callback) {
        $http.delete(CommonVar.url + 'file/delete?id=' + id).success(function (data) {
          callback(data);
        });
      }
    };
  }
})();

